Skip to content

Update cheet-js (js-xlsx) to last version#19

Open
lbAntoine wants to merge 2 commits into
brexis:masterfrom
lbAntoine:master
Open

Update cheet-js (js-xlsx) to last version#19
lbAntoine wants to merge 2 commits into
brexis:masterfrom
lbAntoine:master

Conversation

@lbAntoine
Copy link
Copy Markdown

I've encountered problems when using the package while running an updated version of js-xlsx for file export purposes. I opted to fork the project and just made a minor change to the version of the package.

Before

// There is code before, I'll just use the try and catch to make it shorter
try {
  var workbook = XLS.read(data, { type: 'binary' });

  if (attrs.onread) {
    var handleRead = scope[attrs.onread];
    if (typeof handleRead === "function") {
      handleRead(workbook);
    }
  }
} catch (e) {
  if (attrs.onerror) {
    var handleError = scope[attrs.onerror];
    if (typeof handleError === "function") {
      handleError(e);
    }
  }
}

After

try {
  var workbook = XLSX.read(data, { type: 'binary' }); // The global changed to XLSX on newer versions

  if (attrs.onread) {
    var handleRead = scope[attrs.onread];
    if (typeof handleRead === "function") {
      handleRead(workbook);
    }
  }
} catch (e) {
  if (attrs.onerror) {
    var handleError = scope[attrs.onerror];
    if (typeof handleError === "function") {
      handleError(e);
    }
  }
}

This seemed to fix the problem I had and let me run both this package and the original js-xlsx package for other purposes. Hoping this could help someone else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant